package com.sgb.member.ui.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;

import com.sgb.member.BR;
import com.sgb.member.R;
import com.sgb.member.databinding.ItemDemandQuotationBinding;
import com.sgb.member.entity.DemandQuotationBean;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.PointUtils;
import com.swgk.core.util.StringUtil;

import java.util.List;

public class DemandQuotationAdapter extends BaseRecycleAdapter<DemandQuotationBean> {

    int mCurPage;

    public DemandQuotationAdapter(Context context, int curPage, List<DemandQuotationBean> datas) {
        super(context, R.layout.item_demand_quotation, datas);
        mCurPage = curPage;
    }

    @Override
    public void convert(ItemViewHolder holder, DemandQuotationBean entity) {
        holder.setBinding(BR.itemBean, entity);
        ItemDemandQuotationBinding binding = (ItemDemandQuotationBinding) holder.getmBinding();
        /*String price;
        if (TextUtils.isEmpty(entity.getPrice())) {
            price = "0.00";
        } else {
            price = PointUtils.price(Double.parseDouble(entity.getPrice()));
        }
        String sUnit;
        // 商品带元
        if (TextUtils.isEmpty(entity.getUnit())) {
            sUnit = mCurPage == 0 ? "元" : "";
        } else {
            sUnit = mCurPage == 0 ? "元/" + entity.getUnit() : entity.getUnit();
        }
        String s = price + sUnit;
        binding.tvDemandPrice.setText(s);*/
        // 1待报价，2已完成，3已报价，4已失效
        binding.ivStatus.setVisibility(View.VISIBLE);
        switch (entity.getStatus()) {
            case 4:
                binding.ivStatus.setBackgroundResource(R.mipmap.icon_demand_ysx);
                break;
            case 3:
                binding.ivStatus.setBackgroundResource(R.mipmap.icon_demand_ybj);
                break;
            case 2:
                binding.ivStatus.setBackgroundResource(R.mipmap.icon_demand_ywc);
                break;
            case 1:
                binding.ivStatus.setBackgroundResource(R.mipmap.icon_demand_dbj);
                break;
            default:
                binding.ivStatus.setVisibility(View.GONE);
                break;
        }



        switch (entity.getStatus()){
            case 1:
                break;//待招标
            case 2:
                break;//招标中
            case 3:
                break;//已结束
            case 4:
                binding.ivStatus.setBackgroundResource(R.mipmap.icon_demand_ysx);
                break;//招标结束
            case 9:
                break;//报名中
            default:
                break;
        }
    }

}
